<?php 
$titulo = @$this->session->flashdata('error_title');
$rauter = @$this->session->flashdata('error_router');
?>

<?php if (strlen($titulo) > 0):?>
    <?php if ($rauter == false):
          $style = "errorfalse";
          else:
          $style = "errortrue";
          endif;
    ?>   
<div id="<?php echo $style;?>">
   <?php echo $titulo; ?>
</div>
<?php endif;?>
<script language="javascript">
    // apply filters
    var applyFilter = function()
    {
        
    }
    jQuery(document).ready(function(){
        jQuery("#list").jqGrid({
            url: '<?php echo site_url() ?>/documentosestatuspagina/data/',
            mtype: 'POST',
            datatype: 'json',
            colNames:['Id Documento','Cantidad P&aacute;ginas','Tipo Documento'],
            colModel :[
                       {name:'id_documento', index:'id_documento', width:10,hidden:true},
                       {name:'numero_pagina', index:'numero_pagina', width:10},
                       {name:'titulo_documento', index:'titulo_documento', width:10}],
                       
            pager: jQuery('#pager'),
            hiddengrid: true,
            sortname: 'id_documento',
            rowNum:30,       
            rowList:[30,40,50,60,70],
            sortorder: "DESC",
            height: '100%',
            width: '710',
            imgpath: _base_url + 'public/css/jqgrid/flex/images',
            viewrecords: true,
            multiselect: false,
            onSelectRow: function(ids) 
            {
            	if(ids != null) 
            	{
                	
            		var rec = jQuery("#list").getRowData(ids);
            		lol=ids;

            		jQuery("#list_detalle").setGridParam({url : _site_url + '/documentosestatuspagina/detalleDocumento', page : 1, mtype:'POST',postData:{iddetalle:rec.id_documento}}).setCaption("").trigger('reloadGrid');

            	}
            },
            adjacents: 4,
            jsonReader: { repeatitems : false, id_documento: "0" }
        }).navGrid('#pager',{add:false,del:false,edit:false,search:false,position:"left"})
        
         .navButtonAdd('#pager',{caption:"", buttonimg: _base_url + "public/css/jqgrid/flex/images/text_columns.png", onClickButton:function(){ jQuery("#list").setColumns();} })

         .navButtonAdd('#pager',{caption:"Agregar", buttonimg: _base_url + "public/images/new.png", onClickButton:function(){

        	 var id = jQuery('#pager').getGridParam('selarrrow');
             var id=lol;
             if (id.length > 0) 
             {
                 
                    var ret = jQuery("#list").getRowData(id);
                    window.location = _site_url + '/documentosestatuspagina/add/' + ret.id_documento;

              }else{ 
                  
                    jAlert('Debe seleccionar al menos un registro'); 
                    
                   }
       
             return false; 
           } })

        $('#apply_filter').bind('click', applyFilter);
    });

    var flAuto = true;
    var timeoutHnd; 

    function doSearch(ev)
    { 
          if(!flAuto) return; 
          // var elem = ev.target||ev.srcElement; 
          if(timeoutHnd) 
              clearTimeout(timeoutHnd); 
              timeoutHnd = setTimeout(gridReload,500); 
    } 
     
    function enableAutosubmit(state)
    { 
          flAuto = state; 
          jQuery("#submitButton").attr("disabled",state); 
    }
    
    function gridReload()
    { 
   	      
             var mo_mask = jQuery("#search_mo").val(); 

             var array_search = mo_mask;
          
         	 jQuery("#list").setGridParam({url :'<?php echo site_url() ?>/accion/data/'+array_search, page : 1}).trigger('reloadGrid'); 
    }
</script>
<div class="table_container">
<table>

    <tr>
    	<td><div id="titulo">Documentos de Compa&ntilde;&iacute;a</div></td>
    </tr>
    <tr>
        <td>
            <table id="list" class="scroll"></table>
            <div id="pager" class="scroll" style="text-align:center;"></div>
        </td>
	</tr>
	<?php $this->load->view('detalle_paginas_view');?>
 </table>
</div>

